﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
//using log4net;

namespace RecommenderSystem.misc
{
    //This class reads lines from the given file path.

    public class Reader
    {
//        private static ILog logger = log4net.LogManager.GetLogger(typeof(Reader));

        public static ICollection<String> ReadAllLines(String fileName)
        {
            TextReader textReader = null;
            ICollection<String> dataLines = new LinkedList<String>();
            String readLineData = null;
            int linesCounter = 0;
            try
            {
                textReader = new StreamReader(fileName);
                while ( (readLineData = textReader.ReadLine()) != null)
                {
                    dataLines.Add( readLineData );
                    linesCounter++;
                }
 //               logger.Debug(linesCounter+ " lines read.");
                return dataLines;
            }
            catch (Exception ex)
            {
//                logger.Error("Failed to read line", ex);
                if (textReader != null)
                {
                    textReader.Close();
                }
            }
            return null;

        }


    }
}
